home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / COM / LineShare 3.3.1 folder.sit / LineShare 3.3.1 folder / LineShare 3.3.1 / LineShare Scripts / Teleport Bronze Fax1&ARA&Data < prev    next >
Text File  |  1994-07-01  |  8KB  |  401 lines

  1. ! Version 3.0
  2. !
  3. !$ Use this script with TelePort Class 1 fax software working in the "numeric answers"
  4. !$ mode (FaxSTF,Faxilitate), ARA 1.0 or 2.0,
  5. !$ and a BBS, E-mail or other communication server software
  6. !
  7. ! A cable for hardware handshaking is required -??
  8.  
  9. ^2 Fax Software:     = Enum("FaxSTFェ"="0","Faxilitate"="1","GlobalFax"="2") "0"
  10. ! ------------------------------------------
  11. ! Resetting the modem:
  12. ! ------------------------------------------
  13. @Hangup
  14.   SetTries 2
  15.   HsReset 0,0,17,19,0,0
  16. !
  17. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  18. ! to enter the command mode
  19. !
  20. @Label 1
  21.   Flush
  22.   matchclr
  23.   matchstr 1 2 "OK¥r¥n"
  24.   ChrDelay 1
  25.   write "ATH0V1Q0¥r"
  26.   matchread 20
  27.   Write "+++"
  28.   ChrDelay 0
  29.   DtrClear
  30.   SBreak
  31.   DtrSet
  32. !
  33.   DecTries
  34.   IfTries 1 1
  35.   SerReset 2400,0,8,1
  36.   IfTries 0 1
  37.   SerReset 19200,0,8,1
  38. !
  39. ! OSErr -6019 "Modem error - the modem is not responding"
  40.   exit -6019
  41. @Label 2
  42.   ChrDelay 0
  43.   write "AT&F+FCLASS=0;+FAE=0¥r"
  44.   SetSpeed 2400
  45.   Jsr 100
  46.   exit 0
  47.  
  48. ! ------------------------------------------
  49. !    Receiving incoming calls
  50. ! ------------------------------------------
  51. @ANSWER
  52.   SerReset 2400,0,8,1
  53.   Jsr 80
  54.   Write "ATIS22?¥r"
  55.   MatchClr
  56.   MatchStr 1 8 "¥r¥n^$¥r¥n"
  57.   MatchRead 20
  58.   exit -6019
  59. @Label 8
  60.   SetInfo 0 "^$"
  61.   MatchClr
  62.   MatchStr 1 9 "¥r¥n^$¥r¥n"
  63.   MatchRead 20
  64.   exit -6019
  65. @Label 9
  66.   SetSReg 22 Val("^$")
  67.   Jsr 100
  68. !
  69. ! Set the modem preferred speed first
  70. @Label 10
  71. !
  72. ! Set the common options
  73.   Jsr 70
  74. !
  75. ! Set the speaker and S0
  76.   GetCommand B "Fax" "M"
  77.   GetCommand C "Fax" "L"
  78.   GetCommand D "Fax" "S0"
  79.   SetVar A "S0=2"
  80.   ifStr D 11 "S0=0"
  81.   ifStr D 11 ""
  82.   SetVar A "^D"
  83. @Label 11
  84.   Write "AT^A^B^C+FAE=1¥r"
  85.   Jsr 100
  86.   Write "ATV0+FCLASS=0¥r"
  87.   Jsr 110
  88. !
  89. ! Set the data options
  90.   Jsr 75
  91. !
  92. ! Everything is ready - let's sit and wait for a data call
  93. ! We'll wait for 2 minutes, then reinitiate the modem
  94. !
  95.   Note "Waiting for a Fax/ARA/Data callノ"
  96. @Label 12
  97.   MatchClr
  98.   MatchStr 1 14 "2¥r"
  99.   MatchStr 2 15 "13¥r"
  100.   MatchStr 3 40 "15¥r"
  101.   MatchStr 4 13 "4¥r"
  102.   MatchRead 1200
  103. @Label 13
  104.   Write "ATV1¥r"
  105.   Jsr 100
  106.   SetSpeed 2400
  107.   Jump 10
  108. !
  109. ! "2" ("RING") has been read
  110. @Label 14
  111.   Note "Ringノ"
  112.   Jump 12
  113.  
  114. ! "13" ("DATA") has been read
  115. @Label 15
  116.   Write "ATV1O0¥r"
  117.   MatchClr
  118.   MatchStr 1 16 "CONNECT ^$¥r¥n"
  119.   MatchRead 30
  120.   exit -6019
  121. @Label 16
  122.   SetVar B "^$"
  123.   SetSpeed Val("^B")
  124.  
  125.   IfOpen "Data" 21
  126.   Jump 30
  127. @Label 21
  128.   IfOpen "ARA" 22
  129.   Jump 35
  130. @Label 22
  131.   Note "Waiting for an ARA frame"
  132.   MatchClr
  133.   MatchStr 1 23 "^$¥r"
  134.   MatchStr 2 28 "¥08¥01¥03¥14¥04¥03¥00¥08¥250¥16¥03"
  135.   MatchStr 3 29 "¥01¥27¥02¥29¥01¥02¥01¥06"
  136.   MatchRead 40
  137.   Jump 24
  138. @Label 23
  139.   QueueInput "^$¥r"
  140. @Label 24
  141.   Note "Non-ARA call"
  142.   Jump 35
  143.  
  144. @Label 28
  145.   Note "ARA 1.0 call"
  146.   Jump 30
  147. @Label 29
  148.   Note "ARA 2.0 call"
  149.   Jump 30
  150.  
  151. @Label 30
  152.   QueueInput "¥r¥nCONNECT ^B¥r¥n"  
  153. @Label 31
  154.   IfOriginate 32
  155.   QueueInput "¥r¥nRING¥r¥n"
  156. @Label 32
  157.   Attach "ARA" (DTR)
  158.  
  159. @Label 35
  160.   GetSReg C "DATA" 4
  161.   QueueInput "¥r^CCONNECT ^B¥r^C"
  162.   ifOriginate 36
  163.   QueueInput "¥r^CRING¥r^C"
  164. @Label 36
  165.   Attach "Data" (DTR,Escape,Break)
  166.  
  167. !
  168. ! Receiving Fax calls
  169. !
  170. @Label 40
  171.   SetSpeed 19200
  172.   MatchClr
  173.   MatchStr 1 41 "1¥r"
  174.   MatchRead 300
  175.   exit -6019
  176. @Label 41
  177. !
  178. ! Fax connection has been established (we read "CONNECT")
  179. ! Put the CONNECT ("1¥r") back to the buffer,
  180. ! if it was an incoming call, put the "RING" before it
  181. @Label 45
  182.   QueueInput "1¥r"
  183.   ifOriginate 47
  184. @Label 46
  185.   QueueInput "2¥r2¥r"
  186. @Label 47
  187.   Attach "Fax" (DTR,Reset(2400),IdleLimit=30)
  188.  
  189. ! ------------------------------------------
  190. ! Originating a call through the "ARA" subport
  191. ! ------------------------------------------
  192. @ORIGINATE "ARA"
  193.   SerReset 2400,0,8,1
  194.   Jsr 80
  195. !
  196. ! Set the common options
  197.   Jsr 70
  198. !
  199. ! Set the communication options:
  200.   Jsr 75
  201. !
  202. ! dial the number
  203.   Write "ATD^1¥r"
  204. !
  205. ! Wait for a modem response
  206.   Jsr 90
  207.   IfStr C 30 "DATA"
  208.   Write "¥r"
  209.   Exit -6019
  210.  
  211. ! ------------------------------------------
  212. ! Originating a call through the "DATA" subport
  213. ! ------------------------------------------
  214. @ORIGINATE "Data" ("¥r¥nLineShare Line is Busy¥r¥nBUSY¥r¥n")
  215.   SerReset 2400,0,8,1
  216.   Jsr 80
  217. !
  218. ! Set the common options
  219.   Jsr 70
  220. !
  221. ! Set the communication options:
  222.   Jsr 75
  223. !
  224. ! dial the number
  225.   Write "ATD^1¥r"
  226.   HsReset *
  227. !
  228. ! Wait for a modem response
  229.   Jsr 90
  230.   IfStr C 35 "DATA"
  231.   Write "¥r"
  232.   Exit -6019
  233.  
  234. ! ------------------------------------------
  235. ! Originating a call through the "Fax" subPort
  236. ! ------------------------------------------
  237. @ORIGINATE "Fax" ("¥r¥nLineShare Line is Busy¥r¥nBUSY¥r¥n")
  238. !
  239. ! Set the "Fax" speed
  240. !
  241.   SerReset 19200,0,8,1
  242.   Jsr 80
  243. !
  244. ! Set the common options
  245. !
  246.   Jsr 70
  247. !
  248. ! Set the Fax mode (Xon/Xoff)
  249.   Write "AT+FCLASS=1¥r"
  250.   Jsr 100
  251. !
  252. ! Now emit all commands that the application has sent to that port,
  253. ! except "FCLASS", etc
  254. !
  255.   EmitClear "+FCLASS","V","E"
  256.   Jsr 60
  257. !
  258. ! Prepare to receive all error result codes, dial the number
  259. !
  260.   Write "ATV0D^1¥r"
  261.   HsReset *
  262.   Jsr 85
  263.   IfStr C 45 "FAX"
  264.   Write "¥r"
  265.   Exit -6019
  266. !
  267. !
  268. ! This section emits all modem commands sent from the client application
  269. ! For each set of commands the "OK" answer is awaited
  270. !
  271. @Label 60
  272.   EmitStart
  273. @Label 61
  274.   EmitCommand 62
  275.   Jsr 100
  276.   Jump 61
  277. @Label 62
  278.   return
  279. !
  280. ! This section initiates the modem before ANSWER and ORIGINATEs:
  281. ! extended responses + connect at the highest rate + speaker control +
  282. ! reset on Dtr drop + DCD valid
  283. ! Verbal responses mode, no echo 
  284. !
  285. @Label 70
  286.   Write "AT&D2&C1V1E0¥r"
  287.   Jsr 100
  288.   return 
  289.  
  290. ! Set the communication options:
  291. ! ・ Normal/AUTO Connection
  292. ! ・ HW flow control  (for ARA, Fax should not use a handshake on receiving)
  293. ! ・ CONNECT <DCE speed> or CARRIER/CONNECT
  294. @Label 75
  295.   return
  296.  
  297. !
  298. ! This section syncronize the modem after the serial port speed switching
  299. !
  300. @Label 80
  301.   ChrDelay 1
  302.   Write "AT¥r"
  303.   ChrDelay 0
  304.   Jsr 100
  305.   return
  306. !
  307. ! Error Codes
  308. @Label 81
  309.   exit -6020
  310. @Label 82
  311.   exit -6022
  312. @Label 83
  313.   exit -6021
  314. @Label 84
  315.   exit -6023
  316.  
  317. !
  318. ! Connecting in the numeric mode (fax)
  319. ! On exit:
  320. ! ^C contains "NONE" if no connection has been established
  321. @Label 85
  322.   MatchClr
  323.   MatchStr 1 88 "1¥r"
  324.   MatchStr 2 87 "2¥r"
  325.   MatchStr 5 81 "6¥r"
  326.   MatchStr 6 82 "7¥r"
  327.   MatchStr 7 83 "3¥r"
  328.   MatchStr 8 84 "8¥r"
  329. @Label 86
  330.   Matchread 1200
  331.   SetVar C "NONE"
  332.   return
  333.  
  334. @Label 87
  335.   Note "Ringノ"
  336.   Jump 86
  337. @Label 88
  338.   SetVar C "FAX"
  339.   return
  340.  
  341. !
  342. ! This subroutine waits for the modem response (data mode)
  343. ! On exit:
  344. ! ^A contains the protocol used
  345. ! ^B contains the carrier speed
  346. ! ^C contains "NONE" if no connection has been established
  347. ! If modem reports an error, the scripts exits with an error code
  348. !
  349. @Label 90
  350.   SetVar A "NONE"
  351.   SetVar B ""
  352.   MatchClr
  353.   Matchstr 5 97 "CONNECT ^$¥r¥n"
  354.   Matchstr 6 94 "RING¥r¥n"
  355.   Matchstr 10 82 "BUSY¥r¥n"
  356.   MatchStr 11 83 "NO CARRIER¥r¥n"
  357.   MatchStr 12 84 "NO ANSWER¥r¥n"
  358. @Label 91
  359.   Matchread 1200
  360.   SetVar C "NONE"
  361.   return
  362.  
  363. @Label 94
  364.   Note "Ringノ"
  365.   Jump 91
  366.  
  367.  
  368. ! CONNECT xxx was detected
  369. @Label 97
  370.   SetVar B "^$"
  371.   SetVar C "DATA"
  372.   return
  373. !
  374. ! Processing an AT command:
  375. ! OK -> proceed
  376. ! ERROR or TimeOut ->exit -6019
  377. ! It can be called AFTER the "Write" command, since LineShare buffers input
  378. !
  379. @Label 100
  380.   MatchClr
  381.   MatchStr 1 103 "¥r¥nOK¥r¥n"
  382.   MatchStr 2 102 "¥r¥nERROR¥r¥n"
  383. @Label 101
  384.   MatchRead 20
  385. @Label 102
  386.   Exit -6019
  387. @Label 103
  388.   return
  389.  
  390. !
  391. ! Processing an AT command in the numeric mode
  392. ! OK -> proceed
  393. ! ERROR or TimeOut ->exit -6019
  394. ! It can be called AFTER the "Write" command, since LineShare buffers input
  395. !
  396. @Label 110
  397.   MatchClr
  398.   MatchStr 1 103 "0¥r"
  399.   MatchStr 2 102 "4¥r"
  400.   Jump 101
  401.